<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>

    <script type="text/javascript">
        var $bn_shop_check_list = new Object();
        var $bn_shop_check_list_Datagrid;
        var $bn_shop_check_list_toolbar = [{
                text:'<i class="fa fa-search" aria-hidden="true"></i>刷新',
                handler:function(){
                    $bn_shop_check_list.reload();
                }
            },
            {
                text:'<i class="fa fa-edit" aria-hidden="true"></i>编辑',
                handler:function(){
                    $bn_shop_check_list.updateInit();
                }
            },'-',{
                text:'<i class="fa fa-check-square-o" aria-hidden="true"></i>审核',
                handler:function(){
                    $bn_shop_check_list.check();
                }
            },'-',
            {
                text:'<i class="fa fa-lock" aria-hidden="true"></i>冻结',
                handler:function(){
                    $bn_shop_check_list.status();
                }
            },
            {
                text:'<i class="fa fa-unlock-alt" aria-hidden="true"></i>取消冻结',
                handler:function(){
                    $bn_shop_check_list.unstatus();
                }
            }
        ];
        $(function(){
            //gird 初始化
            $bn_shop_check_list_Datagrid = $('#bn_shop_check_list_Datagrid').datagrid({
                filterBtnIconCls:'icon-filter',
                queryParams: {
                    filter_EQ_delete_status : 0
                },
                pageSize : 20,
                remoteFilter:true
            });

            $bn_shop_check_list_Datagrid.datagrid('enableFilter', [
                {
                    field:'checkStatus',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        data:json_shzt
                    },
                    op:['equal']
                },{
                    field:'serviceClassifyCode',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        url:'${ctx}/tcode/all/method?method=getCacheCdCooperativeShopsTypeParent'
                    },
                    op:['equal']
                },{
                    field:'serviceTypeCode',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        url:'${ctx}/tcode/all/method?method=getCacheCdCooperativeShopsTypeSubclass'
                    },
                    op:['equal']
                },
                {field:'location',type:'label'},
                {field:'checkAt',type:'label'},
                {field:'checkPersion',type:'label'},
                {field:'status',type:'label'},
                {field:'createAt',type:'label'},
                {field:'t',type:'label'}
            ]);

        });

        //刷新

        $bn_shop_check_list.reload = function(){
            $bn_shop_check_list_Datagrid.datagrid('reload');
        };

        var viewDialog ;

        //编辑
        $bn_shop_check_list.updateInit = function (){
            var row = $bn_shop_check_list_Datagrid.datagrid('getSelected');
            if(row==null) {
                $.messager.alert("提示", errMsg("请选择一行数据！"), "error");
            }else if(row.status=="1"){
                parent.$.messager.alert("提示",errMsg("已冻结，不能编辑！"),"error");
            }else{
                viewDialog = parent.$.dialog({
                    title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;合作商家编辑<span>',
                    href: '${ctx}/bn/shop/check/update?_m=init&id='+row.shopId+'&r='+Math.random(),
                    width: 800,
                    height: 550,
                    modal: true,
                    onClose : function() {
                        $(this).dialog('destroy');
                    },
                    buttons:[{
                        text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>保存',
                        width:'70px',
                        handler:function(){
                            viewDialog.find('iframe').get(0).contentWindow.submitForm(viewDialog, $bn_shop_check_list_Datagrid);
                        }
                    },{
                        text:'<i class="fa fa-reply" aria-hidden="true"></i>返回',
                        width:'70px',
                        handler:function(){
                            viewDialog.dialog('destroy');
                        }
                    }]
                });
            }
        }

        //审核
        $bn_shop_check_list.check = function (){
            var row = $bn_shop_check_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.checkStatus=="1"){
                parent.$.messager.alert("提示",errMsg("已审核，不能重复操作！"),"error");
            }else if(row.status=="1"){
                parent.$.messager.alert("提示",errMsg("已冻结，不能进行审核！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要删除店铺名称【'+row.shopName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/shop/check/check?_m=exec', {id : row.shopId}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","审核成功！","info",function(){
                                    $bn_shop_check_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

        //冻结
        $bn_shop_check_list.status = function (){
            var row = $bn_shop_check_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.status=="1"){
                parent.$.messager.alert("提示",errMsg("已冻结，不能重复冻结！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要删除店铺名称【'+row.shopName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/shop/check/status?_m=exec', {id : row.shopId}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","冻结成功！","info",function(){
                                    $bn_shop_check_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

        //取消冻结
        $bn_shop_check_list.unstatus = function (){
            var row = $bn_shop_check_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.status=="0"){
                parent.$.messager.alert("提示",errMsg("未冻结，不能进行取消冻结！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要删除店铺名称【'+row.shopName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/shop/check/unstatus?_m=exec', {id : row.shopId}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","取消冻结成功！","info",function(){
                                    $bn_shop_check_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }
    </script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">
        <table id="bn_shop_check_list_Datagrid"  style="width:100%;height:100%"
               data-options="border:false,rownumbers:true,autoRowHeight:false,singleSelect:true,pagination:true,sortName:'seq',sortOrder:'asc',toolbar:$bn_shop_check_list_toolbar,rowStyler: function(index,row){return {style:'height:30px'};},url:'${ctx}/bn/shop/check/search?_m=load',method:'post'">
            <thead>
            <tr>
                <th data-options="field:'shopNo',width:100,align:'center'">店铺编号</th>
                <th data-options="field:'shopName',width:150,align:'center'">店铺名称</th>
                <th data-options="field:'shopShortName',width:120,align:'center'">店铺简称</th>
                <th data-options="field:'seq',width:80,align:'center'">排序</th>
                <th data-options="field:'serviceClassifyCode',width:150,align:'center',formatter:
                    function(value,row,index){
                       return row.serviceClassifyName;
                    }
                ">服务分类</th>
                <th data-options="field:'serviceTypeCode',width:150,align:'center',formatter:
                    function(value,row,index){
                       return row.serviceTypeName;
                    }
                ">服务类型</th>
                <th data-options="field:'phone',width:120,align:'center'">联系电话</th>
                <th data-options="field:'address',width:200,align:'center'">详细地址</th>
                <th data-options="field:'checkStatus',width:150,align:'center',formatter:
                    function(value,row,index){
                        if(row.checkStatus=='0'){
                            return '未审核';
                        }else if(row.checkStatus=='1'){
                            return '已审核';
                        }
                    }
                ">审核状态</th>
                <th data-options="field:'checkAt',width:150,align:'center'">审核时间</th>
                <th data-options="field:'checkPersion',width:150,align:'center'">审核人</th>
                <th data-options="field:'status',width:150,align:'center',formatter:
                    function(value,row,index){
                        if(row.status=='0'){
                            return '未冻结';
                        }else if(row.status=='1'){
                            return '<span style=\'color:red\'>已冻结</span>';
                        }
                    }
                ">冻结状态</th>
                <th data-options="field:'createAt',width:150,align:'center'">添加时间</th>
                <th data-options="field:'t',width:20,align:'center'"></th>
            </tr>
            </thead>
        </table>
    </div>
</div>
</body>
</html>